<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean"%>
<%@ taglib uri="http://struts.apache.org/tags-html" prefix="html"%>
<%@ taglib uri="http://struts.apache.org/tags-logic" prefix="logic"%>
<%@ taglib uri="http://struts.apache.org/tags-tiles" prefix="tiles"%>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>房产登记</title>
<LINK href="images/css.css" type="text/css" rel="stylesheet">
<script language="javascript">
	var req;
	
	function init() {
		if (window.XMLHttpRequest) {
			req = new XMLHttpRequest();
		} else if (window.ActiveXObject) {
			req = new ActiveXObject("Microsoft.XMLHTTP");
		}
	}
	
	//根据小区ID查询DropChangeAJAXAction，获得该小区的楼栋列表
	function changeDropOfBuilding() {
		init();
		
		var url="dropChangeAJAX.do?method=changeDropOfBuilding&subId="+escape(document.forms[0].subId.options[document.forms[0].subId.selectedIndex].value);
		
		req.open("get", url, true);
		req.onreadystatechange = callback;
		req.send(null);
	}

	//根据楼栋ID查询DropChangeAJAXAction，获得该楼栋的房产列表
	function changeDropOfHouse() {
		init();
		
		var url="dropChangeAJAX.do?method=changeDropOfHouse&buildingId="+escape(document.forms[0].buildingId.options[document.forms[0].buildingId.selectedIndex].value);
		
		req.open("get", url, true);
		req.onreadystatechange = callback;
		req.send(null);
	}
	
	function callback() {
		if (4 == req.readyState) {
			if (200 == req.status) {
				eval(req.responseText);
			}
		}
	}
	function checkForm() {
		var subId = document.forms[0].subId.value;
		var buildingId = document.forms[0].buildingId.value;
		var houseId = document.forms[0].houseId.value;
		var itemIds = document.forms[0].itemIds.value;

		if (subId==0) {
			alert("请选择小区！");
			return false;
		}
		//if (buildingId == 0) {
		//	alert("请选择楼栋！");
		//	return false;
		//}
		//if (houseId == 0) {
		//	alert("请选择房产！");
		//	return false;
		//}
		//if (itemIds == null || itemIds == "") {
			//alert("请选择收费项目！");
			//return false;
		//}
		return true;
	}
   function typeSel(a){
	  
	   var building = document.getElementById('selTr1');
	   var house = document.getElementById('selTr2');
	  if(a == 1){
		  //隐藏楼栋和房产
		building.style.display = "none";
		house.style.display = "none"; 
	  }else{
		  building.style.display = "block";
		  house.style.display = "block";
	  }
 }
</script>

</head>
<body>
<html:form action="regHouse.do?method=save" method="post" onsubmit="return checkForm();">
<table class="tableline" cellspacing="1" cellpadding="0" width="100%"
	border="0">
	<tr>
		<td class="STYLE4" align="center" bgcolor="#ffffff" colspan="2"
			height="40">房产登记</td>
	</tr>
	<tr>
		<td width="217" height="26" align="right" bgcolor="#ffffff">
		物业服务处：</td>
		<td width="773" bgcolor="#ffffff">&nbsp;${dis.name }</td>
	</tr>
	<tr>
		<td width="217" height="26" align="right" bgcolor="#ffffff">小区：</td>
		<td width="773" bgcolor="#ffffff">
		&nbsp;<html:select property="subId" onchange="changeDropOfBuilding()" style="width:120px">
				<html:option value="0">请选择</html:option>
				<c:if test="${!empty subList}">
					<c:forEach items="${subList}" var="sub">
						<html:option value="${sub.id}">${sub.name}</html:option>
					</c:forEach>
				</c:if>
			</html:select>
		</td>	
	</tr>
	<tr>
	  <td width = "217" height = "26" align = "right" bgcolor = "#ffffff">处理方式：</td>
	  <td width = "773" bgcolor = "#ffffff">
	    &nbsp;<html:radio  property = "handleId" value = "1" onclick="typeSel(1)" />批量操作
	    <html:radio property = "handleId" value = "2" onclick="typeSel(2)" />个别操作
	  </td>
	</tr>
	<tr>
		<td width="217" height="26" align="right" bgcolor="#ffffff">楼栋：</td>
		<td width="773" bgcolor="#ffffff" valign="middle">
		&nbsp;<div id = "selTr1" style="float:left;margin:0px;padding:6px;">
			<html:select property="buildingId" onchange="changeDropOfHouse()" style="width:120px">
				<html:option value="0">请选择</html:option>
			</html:select>
			</div>
		</td>
	</tr>
	<tr>
		<td width="217" height="26" align="right" bgcolor="#ffffff">房产编号：</td>
		<td width="773" bgcolor="#ffffff">
		&nbsp;<div id="selTr2" style="float:left;margin:0px;padding:6px;">
			<html:select property="houseId" style="width:120px">
				<html:option value="0">请选择</html:option>
			</html:select>
			</div>
		</td>
	</tr>
	<tr>
		<td width="217" height="26" align="right" bgcolor="#ffffff">收费项目：</td>
		<td width="773" bgcolor="#ffffff">
		<c:if test="${!empty itemList}">
			<c:forEach items="${itemList }" var="item">
				<html:multibox property="itemIds" value="${item.id }" />${item.name}
			</c:forEach>
		</c:if>
		&nbsp;&nbsp;<html:submit value="登记房产"/>
		</td>
	</tr>
</table>
</html:form>
</body>
</html>